package com.example.sls.service.impl.logistics;

import cn.dev33.satoken.stp.StpUtil;
import com.example.sls.pojo.logistics.UserManageTable;
import com.example.sls.pojo.logistics.UserManagement;
import com.example.sls.dao.logistics.UserManagementDao;
import com.example.sls.pojo.user.Users;
import com.example.sls.service.intserfaces.logistics.UserManagementService;
import com.example.sls.service.intserfaces.user.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户管理表(UserManagement)表服务实现类
 *
 * @author 蓝江富
 * @since 2024-06-18 10:55:06
 */
@Service
public class UserManagementServiceImpl implements UserManagementService {
  @Autowired
  UserManagementDao userManagementDao;
  @Autowired
  UsersService usersService;
  @Override
  public UserManagement queryById(Integer id) {
    return userManagementDao.queryById(id);
  }
  @Override
  public List<UserManageTable> getTableData() {
    return userManagementDao.getTableData();
  }
  @Override
  public int deleteById(Integer id) {
    return userManagementDao.deleteById(id);
  }
  @Override
  public int update(UserManagement userManagement) {
    return userManagementDao.update(userManagement);
  }
  @Override
  public int insert(UserManagement userManagement) {
    return userManagementDao.insert(userManagement);
  }
  @Override
  public long count() {
    return userManagementDao.count();
  }
  @Override
  public List<UserManagement> queryAllByLimit(UserManagement userManagement, Integer pageSize, Integer offset) {
    return userManagementDao.queryAllByLimit(userManagement, pageSize, offset);
  }
  // 将UserManageTable转换为UserManagement的方法
  @Override
  public UserManagement UT_to_UM(UserManageTable userManageTable) {
    UserManagement userManagement=new UserManagement();
    userManagement.setId(userManageTable.getId());
    userManagement.setBlacklist(userManageTable.getBlacklist());
    userManagement.setBlacklistDays(userManageTable.getBlacklistDays());
    Users users=new Users();
    users.setUsername(userManageTable.getUserName());
    userManagement.setUserId(usersService.queryAllByLimit(users,9999,0).get(0).getId());
    return userManagement;
  }
}
